package com.example.mytayunapi.Controller;

import com.example.mytayunapi.Entity.PurchaseRequestInfo;
import com.example.mytayunapi.Service.PurchaseRequestInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("purchaserequest")
public class PurchaseRequestController {
    @Autowired
    private PurchaseRequestInfoService purchaseRequestInfoService;

    //http://localhost:8080/purchaserequest/request
    @GetMapping("/request")
    public List<PurchaseRequestInfo> selectPurchaseRequestsByUserId(@RequestParam("userId") String userId) {
        return purchaseRequestInfoService.selectPurchaseRequestsByUserId(userId);
    }


    //http://localhost:8080/purchaserequest/delete
    @PostMapping("/delete")
    public Integer deletePurchaseRequest(@RequestParam Integer pmId) {
        return purchaseRequestInfoService.deletePurchaseRequest(pmId);
    }
}
